<template>
  <div class="deviceRealTimeStatus">
    <div class="circle">
      <div class="num">{{ detail.totalVolume }}</div>
      <div class="tit">累计净水量</div>
      <div>（升）</div>
      <img src="@/assets/circle_bg.png" alt="" />
    </div>
    <div class="total">
      <div class="total-num">{{ detail.deviceNum }}<span class="unit">台</span></div>
      <div class="tit">设备总数</div>
    </div>
    <div class="info">
      <div class="item">
        <span class="num">{{ detail.onlineNum }}</span>
        <span class="tit">在线设备</span>
      </div>
      <div class="item">
        <span class="num">{{ detail.chipNum }}</span>
        <span class="tit">需换芯</span>
      </div>
      <div class="item">
        <span class="num">{{ detail.expireNum }}</span>
        <span class="tit">已到期</span>
      </div>
      <div class="item">
        <span class="num">{{ detail.errorNum }}</span>
        <span class="tit">有故障</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { getDataStatistics } from '@/api'
import useInterval from '@/hooks/useInterval'
import config from '@/utils/config'
const detail: any = ref({})

useInterval(() => {
  getDataStatistics({}).then((res) => {
    detail.value = res
  })
}, config.internalTime)
</script>

<style lang="scss" scoped>
.deviceRealTimeStatus {
  height: 322px;
  width: 100%;
  display: flex;
  align-items: center;
  color: #fff;
  padding: 0px 40px 20px 80px;
  .circle {
    position: relative;
    height: 180px;
    width: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 16px;
    padding-top: 20px;
    .num {
      // margin: 4px 0;
      color: #69e4b2;
      font-size: 30px;
      font-weight: 700;
    }
    .tit {
      margin-top: 10px;
    }
    img {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }
  }
  .total {
    display: flex;
    flex-direction: column;
    // width: 280px;
    min-width: 180px;
    margin-left: 38px;
    align-items: center;
    .total-num {
      color: #f4b13e;
      font-size: 42px;
      font-weight: 700;
      .unit {
        margin-left: 4px;
        font-size: 15px;
        font-weight: 700;
        position: relative;
        top: -4px;
      }
    }
    .tit {
      color: #3aa0ff;
      font-size: 22px;
      margin-top: 0px;
    }
  }
  .info {
    display: flex;
    width: 320px;
    flex-wrap: wrap;
    position: relative;
    top: -26px;
    .item {
      margin-top: 40px;
      width: 160px;
      display: flex;
      flex-direction: column;
      align-items: center;
      .num {
        color: #fff;
        font-size: 24px;
        font-weight: 700;
      }
      .tit {
        color: #5daebd;
      }
    }
  }
}
</style>
